/*
 * CS_WEEKEND_RANK_TIME.cpp
 *
 *  Created on: 2013. 7. 23.
 *      Author: the2
 */

#include "../../Command.h"
#include "../../User.h"
#include "../../NLogic/Function.h"

namespace ProjectZ { namespace NCommand {

void Command::CS_WEEKEND_RANK_TIME(User * pUser, ::Network::Packet * pPacket)
{
	PREPARE_PACKET;

	::Network::Packet * ack = ::Network::GETPACKETPOOL()->SEND_NEW();


	time_t weekInitTime = 0;
	if (false == ::ProjectZ::Config::Instance().GetResourceDatabase()._isTest)
	{
		weekInitTime = NLogic::NFunction::GetWeekInitTime() + (3600 * 24 * 7);
	}
	else
	{
		int rankCycle = ::ProjectZ::Config::Instance().GetResourceFile()._rankCycle;
		weekInitTime = NLogic::NFunction::GetWeekInitTime() + rankCycle;
	}

	*ack << static_cast<int16_t>(ACK_OK) << static_cast<uint32_t>(weekInitTime - time(NULL));

	ack->MakePacket(CMD_SC_WEEKEND_RANK_TIME);
	pUser->Send(ack);
}

} /*NCommand*/ } /*ProjectZ*/

